#==============================================================================
# WRITE VARIABLE INTO A SPECIFIC LINE  [NOT FOR EXPORT]
#==============================================================================
KeywordWriteLine <- function(fs, ln, value, env = SetEnv()) { 
  #Variable list 
  #fs: file string containing entire parameter file
  #ln: line number to read
  #vs: variable character string to insert

  #check is character string is vector or scalar
  if (length(value) > 1) {
    vs <- paste(value, sep="", collapse=env$vecchar)
  }
		
  line    <- str_trim(fs[ln], side = "both") #assign line, but first remove leading/trailing blanks
  varname <- unlist(strsplit(line, env$splchar, fixed = TRUE))[1] #get variable name	
  line    <- paste(varname, env$splchar, " ", value, sep="")
  fs[ln]  <- line
	
  return(fs)
}